<div id="hyper-subpage" class="container-fluid" style="float:left;">
	<div class="row">
		<div class="col-lg-12">
			<h3 class="page-header"><svg data-src="svg/update.svg" width="28" height="28" fill="currentColor" class="svg4hyperhdr"></svg><span data-i18n="main_menu_update_token">Update</span></h3>
			<div class="callout callout-info">
				<h4 data-i18n="update_label_intro" style="font-size:16px">Overview about all available HyperHDR versions. On top you could update or downgrade your version of HyperHDR whenever you want. Sorted from newest to oldest</h4>
			</div>
			<br />
			<h4 id="update_currver"></h4>
			<hr />			
		</div>
		<div class="col-lg-12">
			<div class="container-fluid">
				<div class="row" id="versionlist"></div>
			</div>
		</div>
	</div>
</div>

<script>
	$(document).ready(function (error) {
		performTranslation();
		getReleases(function (callback) {
			if (callback) {
				var matches = 0;
				for (var key in window.gitHubVersionList) {
				
					if (window.gitHubVersionList[key].name == null)
						continue;
						
					if (window.gitHubVersionList[key].tag_name.includes("beta") ||
						window.gitHubVersionList[key].tag_name.includes("alpha"))
					{
						if (compareHyperHdrVersion(window.currentVersion, window.gitHubVersionList[key].tag_name))
							continue;
					}

					var danger;
					var type;
					var description = DOMPurify.sanitize(marked(window.gitHubVersionList[key].body));
					
					if (description.length < 80)
						continue;

					if (window.gitHubVersionList[key].tag_name.includes("beta")) {
						danger = "bg-warning h5 p-3";
						type = "Beta";
					} else if (window.gitHubVersionList[key].tag_name.includes("alpha")) {
						danger = "bg-danger h5 p-3";
						type = "Alpha";
					} else {
						danger = "card-header";
						type = "Stable";
					}

					matches++;
					$("#versionlist").append(
						'<div class="col-lg-6"><div class="card card-default' +
							'"><div class=" '+danger+'"><svg data-src="svg/update.svg" width="18" height="18" fill="currentColor" class="svg4hyperhdr"></svg>HyperHDR ' +
							window.gitHubVersionList[key].tag_name +
							'</div><div class="card-body"><p><span style="font-weight:bold;">' +
							$.i18n("update_label_type") +
							"</span> " +
							type +
							'</p><p><span id="desc" style="font-weight:bold;">' +
							$.i18n("update_label_description") +
							"</span> " +
							description +
							'</p><hr><a class="btn btn-primary pull-right" href="' +
							window.gitHubVersionList[key].html_url +
							'" target="_blank"><svg data-src="svg/button_link.svg" fill="currentColor" class="svg4hyperhdr"></svg><span style="font-weight:bold;">' +
							$.i18n("update_button_changelog") +
							'</span></a></div></div></div>'
					);
				}
				$("#update_currver").append($.i18n("update_versreminder", currentVersion));

				if (matches == 0) $("#versionlist").append($.i18n("update_no_updates_for_branch"));
			} else {
				$("#versionlist").append($.i18n("update_error_getting_versions"));
			}
		});
		removeOverlay();
	});
</script>

